import React, { Component } from 'react'
import {connect} from "react-redux"
import {Type,Food} from '../../types/food'
import Food_item from '../../component/food_item'
interface Iprops{
    match:any,
    list:Type[]
}

class Classify extends Component<Iprops> {
    componentDidMount(){
        console.log(this.props.match.params.t_id)
    }
    
    render() {
        console.log(this.props.list)
        let food:any = this.props.list.find(item => item.t_id == this.props.match.params.t_id);
        console.log("food",food)
        let foodList = food.children;
        return (
            <div>
                {foodList && foodList.map((item:Food) => <Food_item t_id={this.props.match.params.t_id} {...item}></Food_item>)}
            </div>
        )
    }
}

let stateMapToProps = (state:any) => {
    return {
        list:state.list
    }
}

let dispatchMapToProps = (dispatch:any) => {
    return {

    }
}

export default connect(stateMapToProps,dispatchMapToProps)(Classify)
